package com.ugoodtech.mdcc.web.controller;

/* Copyright (C) Ugoodtech, Inc - All Rights Reserved.
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 * Proprietary and confidential.
 * Written by Stone Shaw.
 */

import com.ugoodtech.mdcc.core.domain.ClientAppVersion;
import com.ugoodtech.mdcc.core.repository.ClientAppVersionRepository;
import com.ugoodtech.mdcc.web.dto.JsonResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

@ApiIgnore
@RestController
@RequestMapping("/clientAppVersion")
public class AppVersionController {

    @Autowired
    private ClientAppVersionRepository clientAppVersionRepository;

    @RequestMapping(method = RequestMethod.GET)
    public JsonResponse getClientAppVersions(

            @RequestParam("keyWord") String keyWord,
            Pageable pageable) {

//        Page<ClientAppVersion> clientAppVersionPage = clientAppVersionRepository.findByVerString(keyWord, pageable);
        return JsonResponse.successResponse();
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public JsonResponse createClientAppVersion(@RequestParam("clientAppVersionId") Long clientAppVersionId,
                                               @RequestParam("content") String content) {
        ClientAppVersion clientAppVersion = clientAppVersionRepository.findOne(clientAppVersionId);
//        clientAppVersionService.processClientAppVersion(clientAppVersion,content);
        return JsonResponse.successResponse();
    }

    @RequestMapping(value = "/getClientAppVersion", method = RequestMethod.GET)
    public JsonResponse getClientAppVersion(
            @RequestParam("clientAppVersionId") Long clientAppVersionId) {
        return JsonResponse.successResponseWithData(clientAppVersionRepository.findOne(clientAppVersionId));
    }

}
